﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
using System.ComponentModel;
using Dextrys.SharePoint;
using Higer.SharePoint.HigerWebService;

namespace Higer.SharePoint.UserControls
{
    public partial class Tasks : BaseUserControl
    {

        #region 属性

        public Tasks()
        {
            _showCount = 10;
            _showMyTask = true;
            _showWaitHandle = true;
            _showOrderTask = true;
        }

        private int _showCount;

        [WebBrowsable(true)]
        [WebDisplayName("显示数量")]
        [Personalizable(PersonalizationScope.User)]
        [Category("webpart部件自定义属性")]
        public int ShowCount
        {
            get { return _showCount; }
            set { _showCount = value; }
        }

        private bool _showMyTask;

        [WebBrowsable(true)]
        [WebDisplayName("显示我的任务")]
        [Personalizable(PersonalizationScope.User)]
        [Category("webpart部件自定义属性")]
        public bool ShowMyTask
        {
            get { return _showMyTask; }
            set { _showMyTask = value; }
        }

        private bool _showWaitHandle;

        [WebBrowsable(true)]
        [WebDisplayName("显示待办事项")]
        [Personalizable(PersonalizationScope.User)]
        [Category("webpart部件自定义属性")]
        public bool ShowWaitHandle
        {
            get { return _showWaitHandle; }
            set { _showWaitHandle = value; }
        }

        private bool _showOrderTask;

        [WebBrowsable(true)]
        [WebDisplayName("显示特殊订单技术任务")]
        [Personalizable(PersonalizationScope.User)]
        [Category("webpart部件自定义属性")]
        public bool ShowOrderTask
        {
            get { return _showOrderTask; }
            set { _showOrderTask = value; }
        }

        #endregion

        #region 事件

        protected void Page_Load(object sender, EventArgs e)
        {
            ShowTasks();
            if (!IsPostBack)
            {
                LBViewWaitHandle_Click(this, null);
            }
            
        }
        

        #endregion

        #region 方法

        public string GetCurrentUserName(string loginName)
        {
            if (loginName.Contains('\\'))
            {
                loginName = loginName.Substring(loginName.IndexOf('\\') + 1);
            }
            return loginName;
        }

        /// <summary>
        /// 裁减字符串到指定的大小
        /// </summary>
        /// <param name="str"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private string GetStringByLength(string str, int len)
        {
            bool fDBCSStarting = false;

            byte[] strArray = System.Text.Encoding.Default.GetBytes(str);
            if (strArray.Length <= len)
            {
                return str;
            }
            else
            {
                len = len - 4;
                byte[] ret = new byte[len + 1];
                for (int i = 0; i < len; i++)
                {
                    ret[i] = strArray[i];
                    // determine if the current byte is the starting byte of a DBCS character
                    if (ret[i].CompareTo((byte)0x7f) > 0)
                        fDBCSStarting = !fDBCSStarting;
                }


                if (fDBCSStarting == true || strArray[len].CompareTo((byte)0x80) < 0)
                    // read the ending byte
                    ret[len] = strArray[len];
                else
                    ret[len] = (byte)'.';

                return System.Text.Encoding.Default.GetString(ret) + "...";
            }
        }

        private void ShowTasks()
        {
            if (!ShowMyTask)
            {
                HiddenCell(CellMyTask);
                HiddenCell(CellMyTaskBlank);
            }
            else
            {
                ShowCell(CellMyTask);
                ShowCell(CellMyTaskBlank);
            }

            if (!ShowWaitHandle)
            {
                HiddenCell(CellWaitHandle);
                HiddenCell(CellWaitHandleBlank);
            }
            else
            {
                ShowCell(CellWaitHandle);
                ShowCell(CellWaitHandleBlank);
            }

            if (!ShowOrderTask)
            {
                HiddenCell(CellOrderTask);
            }
            else
            {
                ShowCell(CellOrderTask);
            }
        }

        private void HiddenCell(HtmlTableCell cell)
        {
            cell.Attributes["style"] = "display:none;position:absolute;";
        }

        private void ShowCell(HtmlTableCell cell)
        {
            cell.Attributes["style"] = "";
        }

        #endregion


        #region 待办事项

        #region 事件

        protected void LBViewWaitHandle_Click(object sender, EventArgs e)
        {
            MVMain.ActiveViewIndex = 1;
            CellMyTask.Attributes["class"] = "TopBorder";
            CellWaitHandle.Attributes["class"] = "SelectedTopBorder";
            CellOrderTask.Attributes["class"] = "TopBorder";

            try
            {
                DataTable dt_WaitHandle = GetWaitHandles(GetCurrentUserName(this.CurrentUser.LoginName));

                //控制任务显示数量
                gvWaitHandle.PageSize = ShowCount;

                if (dt_WaitHandle!=null&&dt_WaitHandle.Rows.Count>0)
                {
                    gvWaitHandle.DataSource = dt_WaitHandle;
                    gvWaitHandle.DataBind();
                    gvWaitHandle.Visible = true;
                    lblWaitHandleMessage.Visible = false;

                    //显示更多按钮
                    if (dt_WaitHandle.Rows.Count > ShowCount)
                    {
                        moreSpanWaitHandle.Visible = true;
                    }
                    else
                    {
                        moreSpanWaitHandle.Visible = false;
                    }
                }
                else
                {
                    gvWaitHandle.Visible = false;
                    moreSpanWaitHandle.Visible = false;
                    lblWaitHandleMessage.Visible = true;
                    lblWaitHandleMessage.Text = "您当前没有需要处理的待办事项!";
                }
            }
            catch (Exception ex)
            {
                divWaitHandle.Visible = false;
                moreSpanWaitHandle.Visible = false;
                lblWaitHandleMessage.Visible = true;
                lblWaitHandleMessage.Text = ex.Message;
            }
            
        }

        #endregion

        #region 方法

        public DataTable GetWaitHandles(string username)
        {
            HigerWorkList higerWorkList = new HigerWorkList();
            DataSet ds = higerWorkList.GetWaitHandles(username);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            else
            {
                return null;
            }
        }

        //public DataTable GetWaitHandles(string username)
        //{
        //    DataTable dt_waithandles = null;

        //    dt_waithandles = new DataTable();

        //    dt_waithandles.Columns.Add("formname");
        //    dt_waithandles.Columns.Add("subject");
        //    dt_waithandles.Columns.Add("appdate");

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[0]["formname"] = "【信息部】 供应商认证和管理IT化";
        //    dt_waithandles.Rows[0]["subject"] = "软件功能设计（供应商认证和管理部分）";
        //    dt_waithandles.Rows[0]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[1]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[1]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[1]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[2]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[2]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[2]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[3]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[3]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[3]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[4]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[4]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[4]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[5]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[5]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[5]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[6]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[6]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[6]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[7]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[7]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[7]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[8]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[8]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[8]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[9]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[9]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[9]["appdate"] = "09/09";

        //    dt_waithandles.Rows.Add(dt_waithandles.NewRow());

        //    dt_waithandles.Rows[10]["formname"] = "【信息部】 系统维护通知";
        //    dt_waithandles.Rows[10]["subject"] = "定于2009年08月13日（星期二）8:00对服务器进行维护,期间将影响系统的正常使用.";
        //    dt_waithandles.Rows[10]["appdate"] = "09/09";

        //    return dt_waithandles;
        //}

        public string GetSubjectText(string subjectText)
        {
            if (subjectText.Contains("&#60;"))
            {
                subjectText = subjectText.Replace("&#60;", "<");
            }
            if (subjectText.Contains("&#62;"))
            {
                subjectText = subjectText.Replace("&#62;", ">");
            }

            return subjectText;
        }



        #endregion

        #endregion

        #region 我的任务

        #region 事件

        protected void LBViewMyTask_Click(object sender, EventArgs e)
        {
            MVMain.ActiveViewIndex = 0;
            CellMyTask.Attributes["class"] = "SelectedTopBorder";
            CellWaitHandle.Attributes["class"] = "TopBorder";
            CellOrderTask.Attributes["class"] = "TopBorder";

            try
            {
                //DataTable dt_MyTask = GetMyTasks("zhouhx");
                DataTable dt_MyTask = GetMyTasks(GetCurrentUserName(this.CurrentUser.LoginName));


                //控制任务显示数量
                gvMyTask.PageSize = ShowCount;

                if (dt_MyTask!=null&&dt_MyTask.Rows.Count>0)
                {
                    gvMyTask.DataSource = dt_MyTask;
                    gvMyTask.DataBind();
                    gvMyTask.Visible = true;
                    lblMyTaskMessage.Visible = false;


                    //显示更多按钮
                    if (dt_MyTask.Rows.Count > ShowCount)
                    {
                        moreSpanMyTask.Visible = true;
                    }
                    else
                    {
                        moreSpanMyTask.Visible = false;
                    }
                }
                else
                {
                    gvMyTask.Visible = false;
                    moreSpanMyTask.Visible = false;
                    lblMyTaskMessage.Visible = true;
                    lblMyTaskMessage.Text = "您当前没有需要处理的我的任务!";
                }

            }
            catch (Exception ex)
            {
                gvMyTask.Visible = false;
                moreSpanMyTask.Visible = false;
                lblMyTaskMessage.Visible = true;
                lblMyTaskMessage.Text = ex.Message;
            }

        }

        protected void gvMyTask_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if ((e.Row.RowIndex >= 0))
            {
                string startdate = e.Row.Cells[3].Text;
                string enddate = e.Row.Cells[4].Text;

                if (startdate != null && enddate != null)
                {
                    DateTime stratDate = Convert.ToDateTime(startdate.ToString());
                    DateTime endDate = Convert.ToDateTime(enddate.ToString());
                    Label lblTitle = e.Row.FindControl("lblTaskTitle") as Label;
                    if (stratDate.CompareTo(DateTime.Today) > 0)
                    {
                        e.Row.CssClass = "myblackcss";
                        lblTitle.ForeColor = Color.Black;
                    }
                    else if (stratDate.CompareTo(DateTime.Today) <= 0 && endDate.CompareTo(DateTime.Today) >= 0)
                    {
                        e.Row.CssClass = "mygreencss";
                        lblTitle.ForeColor = Color.Green;
                    }
                    else if (endDate.CompareTo(DateTime.Today) < 0)
                    {
                        e.Row.CssClass = "myredcss";
                        lblTitle.ForeColor = Color.Red;
                    }

                    if (endDate.CompareTo(DateTime.Today) >= 0 && endDate.CompareTo(DateTime.Today.AddDays(2)) <= 0)
                    {
                        e.Row.CssClass = "mybluecss";
                        lblTitle.ForeColor = Color.Blue;
                    }
                }

            }

            // 隐藏任务开始时间
            e.Row.Cells[3].Visible = false;
            //隐藏任务结束时间
            e.Row.Cells[4].Visible = false;
        }

        #endregion

        #region 方法

        public DataTable GetMyTasks(string username)
        {
            HigerWorkList higerWorkList = new HigerWorkList();
            DataSet ds = higerWorkList.GetMyTasks(username);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            else
            {
                return null;
            }

        }

        //public DataTable GetMyTasks(string username)
        //{
        //    DataTable dt_mytasks = null;

        //    dt_mytasks = new DataTable();
        //    dt_mytasks.Columns.Add("proj_name");
        //    dt_mytasks.Columns.Add("task_name");
        //    dt_mytasks.Columns.Add("task_url");
        //    dt_mytasks.Columns.Add("task_start_date");
        //    dt_mytasks.Columns.Add("task_end_date");

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[0]["proj_name"] = "供应商认证和管理IT化";
        //    dt_mytasks.Rows[0]["task_name"] = "软件功能设计（供应商认证和管理部分）";
        //    dt_mytasks.Rows[0]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[0]["task_start_date"] = "09/05";
        //    dt_mytasks.Rows[0]["task_end_date"] = "09/18";

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[1]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[1]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[1]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[1]["task_start_date"] = "08/12";
        //    dt_mytasks.Rows[1]["task_end_date"] = "09/27";


        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[2]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[2]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[2]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[2]["task_start_date"] = "08/12";
        //    dt_mytasks.Rows[2]["task_end_date"] = "08/27";



        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[3]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[3]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[3]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[3]["task_start_date"] = "09/12";
        //    dt_mytasks.Rows[3]["task_end_date"] = "09/27";

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[4]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[4]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[4]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[4]["task_start_date"] = "08/12";
        //    dt_mytasks.Rows[4]["task_end_date"] = "09/23";

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[5]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[5]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[5]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[5]["task_start_date"] = "08/12";
        //    dt_mytasks.Rows[5]["task_end_date"] = "09/23";

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[6]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[6]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[6]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[6]["task_start_date"] = "08/12";
        //    dt_mytasks.Rows[6]["task_end_date"] = "09/27";

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[7]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[7]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[7]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[7]["task_start_date"] = "08/12";
        //    dt_mytasks.Rows[7]["task_end_date"] = "09/27";

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[8]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[8]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[8]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[8]["task_start_date"] = "08/12";
        //    dt_mytasks.Rows[8]["task_end_date"] = "09/27";

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[9]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[9]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[9]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[9]["task_start_date"] = "09/23";
        //    dt_mytasks.Rows[9]["task_end_date"] = "09/27";

        //    dt_mytasks.Rows.Add(dt_mytasks.NewRow());

        //    dt_mytasks.Rows[10]["proj_name"] = "【信息部】 系统维护通知";
        //    dt_mytasks.Rows[10]["task_name"] = "对服务器进行维护期间将影响系统的正常使用定于2009年08月13日（星期二）8:00";
        //    dt_mytasks.Rows[10]["task_url"] = "http://www.163.com";
        //    dt_mytasks.Rows[10]["task_start_date"] = "09/23";
        //    dt_mytasks.Rows[10]["task_end_date"] = "09/17";
        //    return dt_mytasks;
        //}

        

        public string GetDate(string startdate, string enddate)
        {
            string date = "";
            try
            {
                DateTime dtStartDate = Convert.ToDateTime(startdate);
                startdate = dtStartDate.ToString("MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                DateTime dtEndDate = Convert.ToDateTime(enddate);
                enddate = dtEndDate.ToString("MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            date = startdate + "~" + enddate;
            return date;
        }

        public string GetTaskTitle(string tasktitle, int length)
        {
            string resulttitle = "";
            tasktitle = GetSubjectText(tasktitle);
            resulttitle = GetStringByLength(tasktitle, length);

            return resulttitle;
        }

        #endregion

        #endregion

        #region 特殊订单技术任务

        #region 事件

        protected void LBViewOrderTask_Click(object sender, EventArgs e)
        {
            MVMain.ActiveViewIndex = 2;
            CellMyTask.Attributes["class"] = "TopBorder";
            CellWaitHandle.Attributes["class"] = "TopBorder";
            CellOrderTask.Attributes["class"] = "SelectedTopBorder";

            try
            {
                //DataTable dTable_crs = GetOrderTasks("caoyang");
                DataTable dt_OrderTask = GetOrderTasks(GetCurrentUserName(this.CurrentUser.LoginName));

                //控制任务显示数量
                gvOrderTask.PageSize = ShowCount;

                if (dt_OrderTask!=null&&dt_OrderTask.Rows.Count>0)
                {
                    gvOrderTask.DataSource = dt_OrderTask;
                    gvOrderTask.DataBind();
                    gvOrderTask.Visible = true;
                    lblOrderTaskMessage.Visible = false;

                    //显示更多按钮
                    if (dt_OrderTask.Rows.Count > ShowCount)
                    {
                        moreSpanOrderTask.Visible = true;
                    }
                    else
                    {
                        moreSpanOrderTask.Visible = false;
                    }
                }
                else
                {
                    gvOrderTask.Visible = false;
                    moreSpanOrderTask.Visible = false;
                    lblOrderTaskMessage.Visible = true;
                    lblOrderTaskMessage.Text = "您当前没有需要处理的特殊订单技术任务!";
                }

            }
            catch (Exception ex)
            {
                gvOrderTask.Visible = false;
                moreSpanOrderTask.Visible = false;
                lblOrderTaskMessage.Visible = true;
                lblOrderTaskMessage.Text = ex.Message;
            }


        }

        protected void gvOrderTask_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            if ((e.Row.RowIndex >= 0))
            {
                string requestdate = e.Row.Cells[4].Text;

                if (requestdate != null&&requestdate!=""&&requestdate!="&nbsp;")
                {
                    DateTime requestDate = Convert.ToDateTime(requestdate.ToString());

                    if (requestDate.CompareTo(DateTime.Today) > 0)
                    {
                        e.Row.CssClass = "myblackcss";
                    }
                    else if (requestDate.CompareTo(DateTime.Today) == 0)
                    {
                        e.Row.CssClass = "mygreencss";
                    }
                    else if (requestDate.CompareTo(DateTime.Today) < 0)
                    {
                        e.Row.CssClass = "myredcss";
                    }
                }
                else
                {
                    e.Row.CssClass = "myblackcss";
                }

            }

            //隐藏要求完成时间
            e.Row.Cells[4].Visible = false;
        }

        #endregion

        #region 方法

        public DataTable GetOrderTasks(string username)
        {
            HigerWorkList higerWorkList = new HigerWorkList();
            DataSet ds = higerWorkList.GetOrderTasks(username);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            else
            {
                return null;
            }

        }


        public string GetRequestDate(string requestDate)
        {
            string date = "";
            //date = t1.ToString("mm/dd") + "~" + t2.ToString("mm/dd");
            if (!requestDate.Equals(""))
            {
                try
                {
                    DateTime dtRequestDate = Convert.ToDateTime(requestDate);
                    requestDate = dtRequestDate.ToString("MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                date = requestDate + "(技术)";
            }

            return date;
        }

        public string GetFristLineDate(string fristLineDate)
        {
            string date = "";
            //date = t1.ToString("mm/dd") + "~" + t2.ToString("mm/dd");
            if (!fristLineDate.Equals(""))
            {
                try
                {
                    DateTime dtFristLineDate = Convert.ToDateTime(fristLineDate);
                    fristLineDate = dtFristLineDate.ToString("MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                date = fristLineDate + "(生产)";
            }

            return date;
        }

        #endregion

        #endregion

    }
}